<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
       <%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改产品信息</title>
<link href="${pageContext.request.contextPath }/css/styles.css" rel="stylesheet" type="text/css" />
 <link href="${pageContext.request.contextPath }/css/facebox.css" rel="stylesheet" type="text/css" />
 <link href="${pageContext.request.contextPath }/css/common.css" rel="stylesheet" type="text/css" />
  <script src="${pageContext.request.contextPath }/js/jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () { 
    new uploadPreview({ UpBtn: "upload", DivShow: "imgdiv", ImgShow: "imgShow" });
}
function getFullPath(obj) {
	//得到图片的完整路径
	if (obj) {
		//ie
		if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
			obj.select();
			return document.selection.createRange().text;
			}
		//firefox
		else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
			if (obj.files) {
				return obj.files.item(0).getAsDataURL();
				}
			return obj.value;
			}
		return obj.value;
		}
	}
$(document).ready(function() {

	$("#upload").change(function(){
		var strSrc = $("#upload").val();
		
		/* img = new Image();
		img.src = getFullPath(strSrc); */
		//验证上传文件格式是否正确
		var pos = strSrc.lastIndexOf(".");
		var lastname = strSrc.substring(pos, strSrc.length);
		if (lastname != ".jpg" && lastname != ".png") {
			alert("您上传的文件类型为" + lastname + "，图片必须为 jpg或png类型");
		}
	});
		$("#sub").click(function() {

			if($("#upload").val() != ""){
				
				var strSrc = $("#upload").val();
				/* img = new Image();
				img.src = getFullPath(strSrc); */
				//验证上传文件格式是否正确
				var pos = strSrc.lastIndexOf(".");
				var lastname = strSrc.substring(pos, strSrc.length);
				
				if (lastname != ".jpg" && lastname != ".png") {
					alert("您上传的文件类型为" + lastname + "，图片必须为 jpg或png类型");
					return false;
				}  
			}
			if($("#Picture_Name").val() == ""){
				alert("图片名称必填。");
				return false;
			}
		if($("#Brief_Introduction").val() == ""){
			alert("产品简介不能为空");
		}
		if ($("#Name").val() == "") {
			alert("产品名称不能为空。");
			return false;
		}
		if ($("#Brand").val() == "") {
			alert("产品品牌名称不能为空.");
			return false;
		}
		if ($("#Repertoire").val() == "") {
			alert("产品包装清单不能为空");
			return false;
		}
		if ($(this).val() == "") {

			alert("产品功能介绍不能为空。");
			return false;
		}
	});
		$("#Brief_Introductionerror").hide();
		$("#Nameerror").hide();
		$("#Numbererror").hide();
		$("#Branderror").hide();
		$("#Repertoireerror").hide();
		$("#Name").blur(function() {
			if ($("#Name").val() == "") {
				$("#Nameerror").show();
			} else {

				$("#Nameerror").hide();
			}
		});

		$("#Number").blur(function() {
			if ($("#Number").val() == "") {
				$("#Numbererror").show();
			} else {

				$("#Numbererror").hide();
			}
		});
		$("#Brand").blur(function() {
			if ($("#Brand").val() == "") {
				$("#Branderror").show();
			} else {

				$("#Branderror").hide();
			}
		});
		$("#Repertoire").blur(function() {
			if ($("#Repertoire").val() == "") {
				$("#Repertoireerror").show();
			} else {

				$("#Repertoireerror").hide();
			}
		});

$("#Brief_Introduction").blur(function() {
	if ($(this).val() == "") {

		$("#Brief_Introductionerror").show();
	} else {

		$("#Brief_Introductionerror").hide();
	}
});
});
</script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.min.js"></script>

    <!-- MASTER STYLESHEET-->
    <link href="${pageContext.request.contextPath }/css/styles.css" rel="stylesheet" type="text/css" />
    
    <!-- LOAD TIPSY TOOLTIPS-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.tipsy.js"></script>
   
    <!-- LOAD CUSTOM JQUERY SCRIPTS-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/scripts.js"></script>	
    
	 <!-- LOAD FACEBOX -->
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/facebox.js"></script>
    <link href="${pageContext.request.contextPath }/css/facebox.css" rel="stylesheet" type="text/css" />
    

    <!-- LOAD FLOT GRAPHS -->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.flot.pack.js"></script>
    <!--[if IE]>
     <script language="javascript" type="text/javascript" src="js/excanvas.pack.js"></script>
    <![endif]-->
    
    
    <!--[if IE 6]>
    <script src="js/pngfix.js"></script>
    <script>
        DD_belatedPNG.fix('.png_bg');
    </script>        
    <![endif]-->

	
    <!-- LOAD GRAPH JAVASCRIPT FILE-->
	<script src="${pageContext.request.contextPath }/js/graphs.js" type="text/javascript"></script>
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script src="${pageContext.request.contextPath }/js/uploadPreview.js" type="text/javascript"></script>
<style type="text/css">
#preview{width:260px;height:190px;border:1px solid #000;overflow:hidden;}
#imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);}
body { overflow-x: hidden; overflow-y: auto; } 
</style>

</head>
<body>
	<div class="result-wrap" style="margin-left: 10%;">
            <form action="${pageContext.request.contextPath }/product/updateProduct.action" method="post" enctype="multipart/form-data">
                <div class="config-items">
                    <div class="config-title">
                        <h1>修改产品</h1>
                    </div>
                    <div class="result-content">
                        <table width="100%" class="insert-tab">
                           <s:iterator value="#request.list" var="i">
                            <tr>
                                <th width="15%"><i class="require-red">*</i>产品类型：</th>
                                <td>
                                	<s:if test="#i.Type_Name == '' || #i.Type_Name == null">
                                	<input type="text" readonly="readonly" id="Type" name="Type" value="<s:property value="Type.firstType.Type_Name"/>-<s:property value="Type.Type_Name"/>" size="85" class="common-text">
                                	</s:if>
                                	<s:else>
                                	<input type="text" readonly="readonly" id="Types" name="Types" value="<s:property value="Type_Name.secondType.firstType.Type_Name"/>-<s:property value="Type_Name.secondType.Type_Name"/>-<s:property value="Type_Name.Type_Name"/>" size="85" class="common-text">
                                	</s:else>
                                	<%-- <select name="Type_Name" class="common-text" style="width: 625px;">
                                		<option><s:property value="Type"/></option>
                                	</select> --%>
                                </td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>产品名称：</th>
                                <td><input type="text" readonly="readonly" id="Name" name="Name" value="<s:property value="Name"/>" size="85" class="common-text">
                               </td>
                            </tr>
 						<tr>
							<th width="15%"><i class="require-red">*</i>产品编号：</th>
							<td><input type="text" id="Number" name="Number" value="<s:property value="Number"/>"
								size="85" class="common-text">
								<font id="Numbererror" style="color: red;">不能为空。</font></td>
						</tr>
						<tr>
							<th width="15%"><i class="require-red">*</i>产品品牌：</th>
							<td><input type="text" id="Name" name="Brand" value="<s:property value="Brand"/>"
								size="85" class="common-text">
								<font id="Branderror" style="color: red;">不能为空。</font></td>
						</tr>
						<tr>
							<th width="15%">包装清单：</th>
							<td><input type="text" id="Repertoire" name="Repertoire" value="<s:property value="Repertoire"/>"
								size="85" class="common-text">
								<font id="Repertoireerror" style="color: red;">不能为空。</font></td>
						</tr>
						<tr>
							<th width="15%">功能模块：</th>
							<td><input type="text" id="Function" name="Function" value="<s:property value="Function"/>"
								size="85" class="common-text">
						</tr>
						<tr>
							<th width="15%">适用行业：</th>
							<td><input type="text" id="Apply" name="Apply" value="<s:property value="Apply"/>"
								size="85" class="common-text">
						</tr>
						<tr>
							<th width="15%">产品报价：</th>
							<td><input type="text" id="Price" name="Price" value="<s:property value="Price"/>"
								size="85" class="common-text">
						</tr>
						<tr>
							<th width="15%">其他：</th>
							<td><input type="text" id="Other" name="Other" value="<s:property value="Other"/>"
								size="85" class="common-text">
						</tr>
						<tr>
							<th width="15%">产品网络服务：</th>
							<td>
							<textarea cols="6" rows="3" id="Service" name="Service" class="wysiwyg"><s:property value="Service"/></textarea></td>
						</tr>                           
                            <tr>
                                <th width="15%"><i class="require-red">*</i>产品简介：</th>
                                <td>
                                <textarea cols="6" rows="3" id="Brief_Introduction" name="Brief_Introduction" class="wysiwyg"><s:property value="Brief_Introduction"/></textarea>
                               <%--  <input type="text" id="Brief_Introduction" name="Brief_Introduction" value="<s:property value="Brief_Introduction"/>" size="85" class="common-text"> --%>
                                <font id="Brief_Introductionerror" style="color: red;">不能为空。</font></td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>是否发布：</th>
                                <td>
                  					<select style="width: 625px;" name="IsPublish" class="common-text">
                  						<option value="false">否</option>
                            			<option value="true">是</option>
                  					</select>              
                                </td>
                            </tr>
                            <tr>
                                	<th></th>
                                	<th align="left"><div id="imgdiv" align="left"><img id="imgShow" src="<s:property value="Picture"/>" width="100" height="100" /></div></th>
                                </tr>
                                 <tr>
                                    <th><i class="require-red">*</i>上传图片：</th>
                                    <td><input style="width: 64%" type="file" id="upload" size="85" name="upload" class="common-text">
                                    <span style="color: red;font-size: 12px;">请选择jpg或png格式的图片</span></td>
                                </tr>
                               
                                <tr>
                                    <th><input type="hidden" id="id" name="id" value='<s:property value="Id"/>'></th>
                                    <td>
                                    
                                        <input type="submit" value="提交" class="btn btn-primary btn6 mr10">
                                        <input type="button" value="返回" onclick="history.go(-1)" class="btn btn6">
                                    </td>
                                </tr></s:iterator>
                            </table>
                    </div>
				</div>
			</form>
		</div>
</body>
</html>